import { Menu } from "antd";
import { Link, useLocation } from "react-router-dom";

export default ({ data, isdark, getSelectKey = () => {} }) => {
    const location = useLocation();
    const selectKey = String(getSelectKey(location));

    return (
        <Menu
            mode="horizontal"
            theme={isdark ? "dark" : "light"}
            selectedKeys={[selectKey]}
        >
            {data &&
                data.map((item, index) => {
                    return (
                        <Menu.Item key={index}>
                            <Link to={item.path}>{item.name}</Link>
                        </Menu.Item>
                    );
                })}
        </Menu>
    );
};
